import { BrowserWindow } from 'electron/main'

import { preloadPath } from '../config/index.js'

export const createWindow = opitons => {
  const win = new BrowserWindow({
    width: 1440,
    height: 900,
    minHeight: 900,
    minWidth: 1440,
    show: false,
    autoHideMenuBar: true, // 隐藏菜单栏
    webPreferences: {
      nodeIntegration: true, // 允许前端使用node
      preload: preloadPath,
    },
    ...opitons,
  })

  win.on('ready-to-show', () => {
    win.show()
  })

  return win
}
